<template>
  <div>
    <div v-for="(item) in group_experts" :key="item.expert_id" style="margin-bottom: 20px;">
      <div style="font-size: 16px;font-weight: bold;">
        {{ `${item.teacher_name}` }}
      </div>
      <el-radio-group v-model="item.prelection_result" class="flex_center_align" style="padding: 10px 0">
        <el-radio :label="1">通过</el-radio>
        <el-radio :label="0">不通过</el-radio>
      </el-radio-group>
      <el-input
        v-model="item.prelection_expert_comment"
        show-word-limit
        :autosize="{minRows: 3}"
        placeholder="请输入内容"
        type="textarea"
      />
    </div>
    <div class="sun-drawer-base-btn flex_end" style="margin-top: 40px">
      <el-button size="mini" @click="goBack">取 消</el-button>
      <el-button v-for="btn in footerBtn" :key="btn.model" type="primary" size="mini" @click="dialogOperationsBnt(btn)">
        {{ btn.name }}
      </el-button>
    </div>
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
  name: 'ProcessCommonEvaluationDataBank',
  components: {
  },
  props: {
    obj: {
      type: Object,
      default() {
        return {}
      }
    },
    footerBtn: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      group_experts: []
    }
  },
  computed: {
    ...mapGetters([
      'publicRoute'
    ]),
    show_prelection_result() {
      return this.$parent.$parent.show_prelection_result
    }
  },
  watch: {
    show_prelection_result: {
      handler: function(show) {
        if (show) {
          this.setFormData()
        }
      }
    }
  },
  created() {
    if (this.show_prelection_result) {
      this.setFormData()
    }
  },
  methods: {
    setFormData() {
      const _that = this
      _that.group_experts = []
      const dataList = this.$parent.$parent.currentItem.group_experts
      dataList.forEach(element => {
        const data = {
          expert_id: element.teacher_id,
          teacher_name: element.teacher.name,
          prelection_result: '',
          prelection_expert_comment: ''
        }
        _that.group_experts.push(data)
      })
    },
    async dialogOperationsBnt(btn) {
      Object.assign(this.$parent.$parent.currentItem, { results: this.group_experts })
      this.$parent.$parent.initReserveSelection()
      this.$parent.$parent.dialogOperationsBnt(btn)
    },
    async goBack() {
      // Object.assign(this.$parent.$parent.currentItem, { results: this.group_experts })
      this.$parent.$parent.initReserveSelection()
      this.$parent.$parent.setShowHidden(['show_prelection_result'])
    }
  }
}
</script>
<style lang="scss" scoped>
  @import '@/styles/sun-style.scss';
</style>
